# coding=utf-8
"""
author: jamon
"""
from enum import IntEnum, unique
import pygame


_need_reload = True


class UserEvent(object):
    """自定义事件"""

    GEN_NPC_TANK = pygame.constants.USEREVENT + 1


@unique
class HpStatus(IntEnum):
    """血量状态"""
    NORMAL = 0   # 正常
    BROKEN = 1   # 部分损坏中
    DEAD = 2     # 死亡


@unique
class MoveDirection(IntEnum):
    NONE = 0   # 无明显朝向
    UP = 1
    DOWN = 2
    LEFT = 3
    RIGHT = 4

    @staticmethod
    def all_types():
        return [m.value for m in MoveDirection]

    @staticmethod
    def compare_direction(direct_1: 'MoveDirection', direct_2: 'MoveDirection') -> int:
        """
        方向比较
        :param direct_1:
        :param direct_2:
        :return: int, 0: 方向相等， 1： 方向相反， 2：方向垂直, 默认返回2
        """
        if direct_1 == direct_2:
            return 0
        if MoveDirection.UP == direct_1:
            if MoveDirection.DOWN == direct_2:
                return 1
        elif MoveDirection.DOWN == direct_1:
            if MoveDirection.UP == direct_2:
                return 1
        elif MoveDirection.RIGHT == direct_1:
            if MoveDirection.LEFT == direct_2:
                return 1
        elif MoveDirection.LEFT == direct_1:
            if MoveDirection.RIGHT == direct_2:
                return 1
        return 2


class Faction(object):
    NONE = 0              # 无势力方
    OUR_FACTION = 1       # 己方阵营
    NPC = 2               # NPC
    ENEMY_FACTION = 2     # 敌方势力


@unique
class GroupIdConst(IntEnum):
    TANK = 1000            # 坦克
    WEAPON = 1001          # 武器
    BULLET = 1002          # 子弹
    STATIC_ENTITY = 1003   # 静态实体


@unique
class TypeIdConst(IntEnum):

    # 坦克类
    TANK_LEVEL_1_1 = 100000101
    TANK_LEVEL_2_1 = 100000201
    TANK_LEVEL_3_1 = 100000301

    # 武器类1001...
    WEAPON_1 = 100100101
    WEAPON_2 = 100100201
    WEAPON_3 = 100100301

    # 子弹类1002...
    BULLET_1 = 100200101
    BULLET_2 = 100200201
    BULLET_3 = 100200301

    # 静态实体类
    ENTITY_BRICK_WALL = 100300101    # 土墙
    ENTITY_IRON_WALL = 100300201     # 铁墙
    ENTITY_BORDER_WALL = 100300301    # 边界
    ENTITY_HOME = 100300401          # 大本营
    ENTITY_ICE = 100300501          # 冰
    ENTITY_TREE = 100300601         # 树
    ENTITY_RIVER = 100300701        # 河

    # 技能类
    SKILL_HURT_ALL_NPC = 100400101      # 对全屏npc产生1次伤害
    SKILL_STOP_ALL_NPC = 100400102      # 全屏npc时间静止buff
    SKILL_WEAPON_UPGRADE_C = 100400201  # 武器升级到C级
    SKILL_WEAPON_UPGRADE_B = 100400202  # 武器升级到B级
    SKILL_SPEED_UP_BUFF = 100400301     # 移动速度加速buff
